package kr.parking.varidator;

import kr.parking.domain.ParkingCommand;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;


public class ParkingValidator  implements Validator{
	
	@Override
	public boolean supports(Class<?> clazz) {
		return ParkingCommand.class.isAssignableFrom(clazz);
	}
	
	@Override
	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "p_name", "required");		
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "p_phone", "required");		
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "p_addr", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "p_count", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "p_cost", "required");
	}
}
